﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace neside3.func_edit
{
    /// <summary>
    /// TabPage.xaml 的交互逻辑
    /// </summary>
    public partial class TabPage : UserControl
    {
        public TabPage()
        {
            InitializeComponent();
        }
        public TabPage(string filename)
        {
            InitializeComponent();
            this.titleFullname.Text = filename;
            this.grid.RowDefinitions[0].Height = new GridLength(24);

        }
        bool miss = false;
        public void SetNormal()
        {
            this.Container.IsEnabled = true;
            this.grid.RowDefinitions[0].Height = new GridLength(24);
        }
        public void SetOutChange()
        {
            miss = false;
            this.Container.IsEnabled = false;
            this.txtWarn.Text = "这个文件被从外部改变,你需要决定怎么处理/This file is had changed out the IDE,how deal it.";
            this.grid.RowDefinitions[0].Height = new GridLength(72);
            this.close_or_reload.Content = "重载入/Reload";
        }
        public void SetOutMiss()
        {
            miss = true;
            this.Container.IsEnabled = false;
            this.txtWarn.Text = "这个文件已从外部删除,你需要决定怎么处理/This file is had changed out the IDE,how deal it.";
            this.grid.RowDefinitions[0].Height = new GridLength(72);
            this.close_or_reload.Content = "关闭/Close";
        }
        public void SetContent(UIElement ele)
        {
            this.Container.Child = ele;
        }
        public event Action onClose;
        public event Action onReload;
        public event Action onIgnore;

        private void close_or_reload_Click(object sender, RoutedEventArgs e)
        {
            if (miss)
                onClose?.Invoke();
            else
                onReload?.Invoke();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            onIgnore?.Invoke();
        }
    }
}
